package org.example.net;

import lombok.SneakyThrows;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.charset.StandardCharsets;

/**
 * @Auther:Liu
 * @Testname:DemoA2
 * @Date:2025/8/27 17:20
 */
public class DemoA2 {
   @SneakyThrows
    public static void main(String[] args) {
       Socket socket = new Socket("127.0.0.1", 8888);
       System.out.println("通讯已开启");
       InputStream inputStream = socket.getInputStream();
       byte[] bytes = new byte[1024];
       int read = inputStream.read(bytes);
       String s = new String(bytes, 0, read, StandardCharsets.UTF_8);
       System.out.println(s);
   }
}
